package com.koron.css2.serviceManage.service;

import com.koron.css2.serviceManage.bean.TService;
import com.koron.css2.serviceManage.mapper.TServiceDetailMapper;
import com.koron.css2.serviceManage.mapper.TServiceMapper;
import org.koron.ebs.mybatis.SessionFactory;
import org.koron.ebs.mybatis.TaskAnnotation;
import org.springframework.stereotype.Service;

//import redis.clients.jedis.JedisPool;

/**
 * 服务管理类
 * 
 * @author 陈维杰
 *
 */
@Service
public class ServerService {

//	@Resource
//	public JedisPool jedisPool;

	/**
	 * 根据服务标识，查询相关服务信息
	 * 
	 * @param sessionFactory
	 * @param serviceCode
	 * @return
	 */
	@TaskAnnotation("selectByServiceCode")
	public TService selectByServiceCode(SessionFactory sessionFactory, String serviceCode) {
		TServiceMapper mapper = sessionFactory.getMapper(TServiceMapper.class);
		TServiceDetailMapper detailMapper = sessionFactory.getMapper(TServiceDetailMapper.class);
		TService tService = mapper.selectByServiceCode(serviceCode);
		if (tService != null) {
			tService.settServiceDetails(detailMapper.findServiceDetailByServiceCode(tService.getServiceCode()));
		}
		return tService;
	}
	
	/**
	 * 修改服务调用次数
	 * 
	 * @param sessionFactory
	 * @param serviceCode
	 */
	@TaskAnnotation("updateCountByServiceCode")
	public int updateCountByServiceCode(SessionFactory sessionFactory, String serviceCode) {
		TServiceMapper mapper = sessionFactory.getMapper(TServiceMapper.class);
		return mapper.updateCountByServiceCode(serviceCode);
	}


}
